<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:cc="http://java.sun.com/jsf/composite"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <!-- INTERFACE -->
    <cc:interface>
    </cc:interface>

    <!-- IMPLEMENTATION -->
    <cc:implementation>
        <h:panelGrid columns="5">         
            <h:outputLabel value="Bill No"/>
            <h:outputLabel value="Net Total"/>
            <h:outputLabel value="Item Name"/>
            <h:outputLabel value="Item Code"/>
            <h:outputLabel />
            <p:inputText autocomplete="off"  value="#{searchController.searchKeyword.billNo}" />
            <p:inputText autocomplete="off" value="#{searchController.searchKeyword.netTotal}"/>
            <p:inputText autocomplete="off" value="#{searchController.searchKeyword.itemName}"/>
            <p:inputText autocomplete="off" value="#{searchController.searchKeyword.code}"/>
            <h:outputLabel />
        </h:panelGrid>
        <p:dataTable rowIndexVar="i" id="tblBills" value="#{searchController.bills}" var="bill" >
            <f:facet name="header">
                <h:outputLabel value="TRANSFER RECIEVE"/>
            </f:facet>
            <p:column>
                <p:commandButton ajax="false" value="View Bill" action="pharmacy_reprint_transfer_receive">
                    <f:setPropertyActionListener target="#{pharmacyBillSearch.bill}" value="#{bill}"/>
                </p:commandButton>
            </p:column>
            
            <p:column headerText="Recive No">                        
                <h:outputLabel value="#{bill.insId}"/>                          
            </p:column>
           
            <p:column headerText="Recive By">
                <h:outputLabel value="#{bill.creater.webUserPerson.name}"/>     
                <br/>
                <h:panelGroup rendered="#{bill.cancelled}" >
                    <h:outputLabel style="color: red;" value="Cancelled By " />
                    <h:outputLabel style="color: red;" rendered="#{bill.cancelled}" value="#{bill.cancelledBill.creater.webUserPerson.name}" >                                       
                    </h:outputLabel>
                </h:panelGroup>
            </p:column> 
            <p:column headerText="Staff">                       
                <h:outputLabel value="#{bill.toStaff.person.nameWithTitle}"/>                            
            </p:column> 
            <p:column headerText="Recive At">                      
                <h:outputLabel value="#{bill.createdAt}"/>                       
                <br/>
                <h:panelGroup rendered="#{bill.cancelled}" >
                    <h:outputLabel style="color: red;" value="Cancelled at " />
                    <h:outputLabel style="color: red;" rendered="#{bill.cancelled}" 
                                   value="#{bill.cancelledBill.createdAt}" >
                        <f:convertDateTime pattern="dd MMM yyyy hh mm a"/>
                    </h:outputLabel>
                </h:panelGroup>
            </p:column>



            <p:column headerText="Net Value" filterBy="#{bill.netTotal}" style="text-align: right;"  >             
                <h:outputLabel value="#{bill.netTotal}" >
                    <f:convertNumber pattern="#,##0.00"/>
                </h:outputLabel>                  
            </p:column>

            <p:column headerText="Comments" >
                <h:outputLabel rendered="#{bill.refundedBill ne null}" value="#{bill.refundedBill.comments}" >
                </h:outputLabel>
                <h:outputLabel  rendered="#{bill.cancelledBill ne null}" value="#{bill.cancelledBill.comments}" >
                </h:outputLabel>
            </p:column>
        </p:dataTable>
    </cc:implementation>
</html>